use serde::{Deserialize, Serialize};

#[derive(Debug, Deserialize, Serialize, Clone)] 
pub struct BaseGetData<T> {
    pub msg: String,
    pub success: bool,
    pub data: Option<T>,
}

impl<T> BaseGetData<T>
where
    T: Serialize,
{
    pub fn new(msg: String, success: bool, data: Option<T>) -> Self {
        Self { msg, success, data }
    }
    pub fn ok(data: T) -> Self {
        Self::new("请求成功".to_string(), true, Some(data))
    }
    pub fn err(msg: String, success: bool) -> Self {
        Self::new(msg, success, None)
    }
}